﻿//********************************************************************************//
//创建日期：<创建日期，2016-11-15>
//创建作者：<孙雪婷，sunxueting@shanghai3h.com>
//功能说明：深井水价批量调整
//********************************************************************************//
using BLL;
using BLL.Access;
using System;
using System.Collections.Generic;
using System.Data;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using Web.Class;

namespace Web.Pages.QuShui.DiXiaS.JiChuXX
{
    public partial class ShenJingSJPLTZ : BasePage
    {
       
        #region 属性

        /// <summary>
        /// 保存结果集
        /// </summary>
        private DataTable dtSource
        {
            get
            {
                return ViewState["dtSource"] as DataTable;
            }
            set
            {
                ViewState["dtSource"] = value;
            }
        }

        #endregion

        #region 变量
        /// <summary>
        /// 存储过程调用类
        /// </summary>
        SpHelper _SpHelper = new SpHelper();
        #endregion

        #region 事件

        /// <summary>
        /// 页面加载事件
        /// </summary>
        protected void Page_Load(object sender, EventArgs e)
        {
            //第一次页面加载
            if (!IsPostBack)
            {
                LoadData();
            }
        }

     
        /// <summary>
        /// 放弃调整
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        protected void btnCancel_Click(object sender, EventArgs e)
        {
            LoadData();
        }

        /// <summary>
        /// 调整水价
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        protected void btnAdjust_Click(object sender, EventArgs e)
        {
            decimal oldSJ = Convert.ToDecimal(cmbYuanShuiJ.Text);
            decimal newSJ = Convert.ToDecimal(txtXinShuiJ.Text);
            DataTable dtxx = _SpHelper.P_QSJX_SHENJINGSJ(2, BusinessTool.WType, oldSJ, newSJ).Tables[0];
            int msg = Convert.ToInt32(dtxx.Rows[0][0]);
            if (msg > 0)
            {
                PageTools.AlertMsg(this, "调整成功！");
                LoadData();
            }
        }

        #endregion

        #region 方法

        /// <summary>
        /// 数据加载
        /// </summary>
        private void LoadData()
        {
            cmbYuanShuiJ.Items.Clear();
            this.dtSource = _SpHelper.P_QSJX_SHENJINGSJ(1,BusinessTool.WType, null, null).Tables[0];
            for (int i = 0; i < dtSource.Rows.Count; i++)
            {
                cmbYuanShuiJ.Items.Add(Convert.ToDecimal(dtSource.Rows[i]["N_SHUIJIA"]).ToString("0.00"), dtSource.Rows[i]["N_SHUIJIA"]);
            }
            cmbYuanShuiJ.SelectedIndex = 0;
        }

        #endregion        
    }
}